//package com.small.common.aspect;
//
//import java.util.Arrays;
//import java.util.Enumeration;
//
//import javax.servlet.http.HttpServletRequest;
//
//import org.aspectj.lang.JoinPoint;
//import org.aspectj.lang.annotation.AfterReturning;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Before;
//import org.aspectj.lang.annotation.Pointcut;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.stereotype.Component;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//
///**
// * Web日志切面类
// */
//@Aspect
//@Component
//public class WebLogAspect {
//	
//	private Logger logger = LoggerFactory.getLogger(this.getClass());
//	
//	ThreadLocal<Long> startTime = new ThreadLocal<Long>();
//	ThreadLocal<String> requestInfo = new ThreadLocal<String>();
//	
//	/**
//	 * 定义一个切入点
//	 * !execution 排除登录方法
//	 */
//	@Pointcut("execution(public * com.jing.crm..controller.*.*(..))")
//	public void webLog(){}
//	
//	
//	@Before("webLog()")
//	public void doBefore(JoinPoint joinPoint){
//		startTime.set(System.currentTimeMillis());
//		// 接收到请求，记录请求内容
//		logger.info("=======WebLog Recore Start==============================================");
//		ServletRequestAttributes attributes =(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
//		if(attributes!=null){
//		    HttpServletRequest request = attributes.getRequest();
//	        // 记录下请求内容
//	        logger.info("‖　远程主机　‖ : " + request.getRemoteAddr());
//	        requestInfo.set(request.getMethod() + " --> " + request.getRequestURL().toString());
//	        logger.info("‖　请求路径　‖: " + request.getMethod() + " --> " + request.getRequestURL().toString());
//	        logger.info("‖　请求方法　‖: " + joinPoint.getSignature().getDeclaringTypeName()+ "." + joinPoint.getSignature().getName());
//	        //获取所有参数方法一：
//	        Enumeration<String> enu=request.getParameterNames();
//	        StringBuffer sb = new StringBuffer();
//	        while(enu.hasMoreElements()){
//	            String paraName = (String)enu.nextElement();
//	            sb.append(paraName).append(":").append(request.getParameter(paraName)).append(",");
//	        }
//	        logger.info("‖　请求参数　‖: [" + sb.toString() + "]" + Arrays.toString(joinPoint.getArgs()));
//		}
//		
//	}
//	
//	
//	
//	@AfterReturning("webLog()")
//	public void doAfterReturning(JoinPoint joinPoint){
//		// 处理完请求，返回内容
//		logger.info("‖　请求路径　‖: " + requestInfo.get());
//		logger.info("‖　请求耗时　‖ : " + (System.currentTimeMillis()- startTime.get()) + "（毫秒）");
//		logger.info("=======WebLog Record Ended==============================================");
//	}
//}
